# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

if(NOT ENABLE_PYTHON)
    message(WARNING "Please enable IE & nGraph Python API (ie_api and offline_transformations_api) targets to enable Model Optimizer target")
else()
    add_custom_target(model_optimizer DEPENDS ie_api offline_transformations_api ov_ir_frontend pyopenvino)
    if(ENABLE_TESTS)
        add_subdirectory(unit_tests/mock_mo_frontend/ov_mock_mo_frontend)
        add_dependencies(model_optimizer ov_mock_mo_frontend)

        add_subdirectory(unit_tests/mock_mo_frontend/mock_mo_python_api)
        add_dependencies(model_optimizer mock_mo_python_api)
    endif()
endif()

# install

configure_file("${CMAKE_CURRENT_SOURCE_DIR}/automation/version.txt.in"
               "${CMAKE_CURRENT_SOURCE_DIR}/version.txt" @ONLY)

# ie_cpack_add_component(model_optimizer)

install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
        DESTINATION tools/mo
        USE_SOURCE_PERMISSIONS
        COMPONENT tests
        EXCLUDE_FROM_ALL
        PATTERN ".*" EXCLUDE
        PATTERN "automation" EXCLUDE
        PATTERN "requirements_dev.txt" EXCLUDE
        PATTERN "README.md" EXCLUDE
        PATTERN "CMakeLists.txt" EXCLUDE

        PATTERN "openvino/tools/mo/front/caffe/CustomLayersMapping.xml" EXCLUDE
        PATTERN "openvino/tools/mo/utils/convert.py" EXCLUDE
        PATTERN "unit_tests" EXCLUDE
        PATTERN "openvino_mo.egg-info" EXCLUDE
        PATTERN "build" EXCLUDE

        REGEX ".*__pycache__.*" EXCLUDE
        REGEX ".*\\.pyc$" EXCLUDE
        REGEX ".*\\.swp" EXCLUDE
        REGEX ".*\\.DS_Store$" EXCLUDE
        REGEX ".*_test\.py$" EXCLUDE)

install(FILES requirements_dev.txt
        DESTINATION tests/mo
        COMPONENT tests
        EXCLUDE_FROM_ALL)

install(DIRECTORY unit_tests
        DESTINATION tests/mo
        COMPONENT tests
        EXCLUDE_FROM_ALL)

install(DIRECTORY automation
        DESTINATION tests/mo
        COMPONENT tests
        EXCLUDE_FROM_ALL)

install(FILES .coveragerc
        DESTINATION tests/mo
        COMPONENT tests
        EXCLUDE_FROM_ALL)
